// JavaScript Document
define(function (require, exports, module) {
	var SelectElement=require("SelectElement");
	// var Tabs=require("Tabs");
	var FrameWindow=require("FrameWindow");
	var SubmitFrameWindow=require("SubmitFrameWindow");
	var PreviewFrameWindow=require("PreviewFrameWindow");
	var ChineseAmount=require("ChineseAmount");
	var ThousandSeparatorNumber=require("ThousandSeparatorNumber");
	var ThousandSeparatorNumberInput=require("ThousandSeparatorNumberInput");


	var Console=require("Console");
	var Masker=require("Masker");
	var Loading=require("Loading");


	var DateInput=require("DateInput");
	var FrameInput=require("FrameInput");
	var BrowserController=require("BrowserController");

	var ValidateCodeImage=require("module/control/ValidateCodeImage");
	//var CheckSelectList=require("module/control/CheckSelectList");//2016.10.24 add by wangyu

	var HTMLTurbo=function(){}
	window.ht=HTMLTurbo;
	window.ht.masker=null;
	window.ht.loading=null;

	HTMLTurbo.prototype.init=function(context){
		if(typeof(context)=="undefined"){
			this.context=document
		}else{
			this.context=context
		}
		this.update();
	};

	HTMLTurbo.prototype.update=function(){
		/*
		var linkElement=document.createElement("link")
		linkElement.href="http://ip:port/common/HTMLTurbo/0.1.0/HTMLTurbo.css";
		linkElement.rel="stylesheet";
		linkElement.type="text/css";

		document.getElementsByTagName("head")[0].appendChild(linkElement)
		*/
		this.updateConsole();


		this.updateFrameInput();


		this.updateWindowFrame();

		this.updateIframe();
		this.updateInput();
		this.updateTextarea();
		this.updateA();

		this.updateTable();

		this.updateSelect();
		// this.updateTabs();

		this.updateThousandSeparatorNumberContainer()
		this.updateChineseAmountContainer()

		this.updateThousandSeparatorNumberInput()

		//this.updateTemplate();

		this.autoNoticeDialog=new Dialog("#autoNoticeDialog");
		this.autoMinNoticeDialog=new Dialog("#autoMinNoticeDialog");

		this.pagination=new Pagination("#pagination");

		this.updateBridge();

		this.updateQuerySelector();
		this.updateQuerySelectorAll();


		this.updateMasker();
		this.updateLoading();


		this.browserController=new BrowserController();
		//this.checkSelectList=function(){return new CheckSelectList();}//2016.10.24 add by wangyu
		this.updateAClick() //2022.5.12 add by wangyu
	}

	HTMLTurbo.prototype.updateMasker=function(){
		var maskerElements=$(".ht_masker").get(0);
		ht.masker=new Masker();
		if(typeof maskerElements !="undefined"){
			ht.masker.setElement(maskerElements);
		}
	}
	HTMLTurbo.prototype.updateLoading=function(){
		var loadingElements=$(".ht_loading").get(0);

		ht.loading=new Loading();
		if(typeof loadingElements !="undefined"){
			ht.loading.setElement(loadingElements);
		}
		ht.loading.setMasker(ht.masker);
		// ht.loading.close();//add by wangyu 2016.10.10 if reload page then close ht.loading
		//loading.open();
		//loading.close();
	}
	HTMLTurbo.prototype.updateQuerySelector=function(selector){
		if(typeof(document.querySelector)=="undefined"){
			document.querySelector=function(selector){
				return $(selector).get(0);
			}
		};
	}
	HTMLTurbo.prototype.updateQuerySelectorAll=function(selector){
		if(typeof(document.querySelectorAll)=="undefined"){
			document.querySelectorAll=function(selector){
				var elementList=Array();
				var objList=$(selector);
				for(var i=0;i<objList.length;i++){
					elementList.push(objList.get(i));
				}
				return elementList;
			}
		};
	}
	HTMLTurbo.prototype.updateThousandSeparatorNumberContainer=function(){
		var total,i=0;

		var elements=$(".ht_thousandSeparatorNumberContainer",this.context)
		var thousandSeparatorNumberContainer=null;

		total=elements.length;
		for(i=0;i<total;i++){
			thousandSeparatorNumberContainer=new ThousandSeparatorNumberContainer(elements.get(i))
		}
	}
	HTMLTurbo.prototype.updateChineseAmountContainer=function(){
		var total,i=0;

		var elements=$(".ht_chineseAmountContainer",this.context)
		var chineseAmountContainer=null;

		total=elements.length;
		for(i=0;i<total;i++){
			chineseAmountContainer=new ChineseAmountContainer(elements.get(i))
		}
	}
	HTMLTurbo.prototype.updateThousandSeparatorNumberInput=function(){
		var total,i=0;

		var elements=$("input[class=ht_thousandSeparatorNumberInput]",this.context)
		var thousandSeparatorAmountInput=null;

		total=elements.length;
		for(i=0;i<total;i++){
			thousandSeparatorNumberInput=new ThousandSeparatorNumberInput(elements.get(i))
		}
	}

	HTMLTurbo.prototype.updateBridge=function(){
		this.bridgeFrame=document.createElement("iframe")
		this.bridgeFrame.style.display="none";
		this.bridgeFrame.name="bridge"
		document.body.appendChild(this.bridgeFrame);
	}
	HTMLTurbo.prototype.updateConsole=function(){
		if(typeof(console)=="undefined"){
			window.console=function(){}
			window.console.log=function(object){}
		};

		pConsole=console;
	}

	HTMLTurbo.prototype.updateFrameInput=function(){
		var total,i=0;

		var elements=$("[type=frame]",this.context)
		var frameInput=null;

		total=elements.length;
		for(i=0;i<total;i++){
			frameInput=new FrameInput(elements.get(i))
		}
	}
	HTMLTurbo.prototype.updateTemplate=function(){
		var templates=$("template",this.context)
		for(var i=0;i<templates.length;i++){
			templates.eq(0).remove()
		}
	}
	HTMLTurbo.prototype.updateWindowFrame=function(){
		var self=this;
		if(!window.windowFrameOpen){
			window.windowFrameOpen=function(title,src,parentWindow,sizeType,id,obj){
				return self.windowFrameOpen(title,src,parentWindow,sizeType,id,obj)
			}
		}
		if(!window.windowFrameAllClose){
			window.windowFrameAllClose=function(){
				return self.windowFrameAllClose();
			}
		}
		//用于隐藏弹出alert用
		if(!window.windowFrameAllHide){
			window.windowFrameAllHide=function(){
				return self.windowFrameAllHide();
			}
		}
		var submitWindowFrames=$("form[target='submitWindowFrame']",this.context)
		if(!window.submitWindowFrameOpen){
			if(submitWindowFrames.length>0){
				this.submitFrameWindow=new SubmitFrameWindow();
				window.submitWindowFrameOpen=function(title){return self.submitWindowFrameOpen(title)}
			}
		}


		var previewWindowFrames=$("form[target='previewWindowFrame']",this.context)
		if(!window.previewWindowFrameOpen){
			if(previewWindowFrames.length>0){
				this.previewFrameWindow=new PreviewFrameWindow();
				window.previewWindowFrameOpen=function(title){return self.previewWindowFrameOpen(title)}
			}
		}
	}
	HTMLTurbo.prototype.submitWindowFrameOpen=function(title){
		this.submitFrameWindow.open(title);
	}
	HTMLTurbo.prototype.previewWindowFrameOpen=function(title){
		this.previewFrameWindow.open(title);
	}
	HTMLTurbo.prototype.windowFrameOpen=function(title,src,parentWindow,sizeType,id,obj){
		var frameWindow=new FrameWindow();
		this.frameWindows.push(frameWindow);
		frameWindow.open(title,src,parentWindow,sizeType,id,obj)
		return frameWindow;
	}

	HTMLTurbo.prototype.frameWindows=Array();
	HTMLTurbo.prototype.windowFrameAllClose=function(){
		//console.log(this.frameWindows);
		var total=this.frameWindows.length;

		for(var i=0;i<total;i++){
			this.frameWindows[i].close();
			/*this.frameWindows.splice(i,1);
			if(i>0){
				i--
			}
			total--*/
		}
		//this.frameWindows=Array();
		//this.frameWindows.length=0;
	}
	HTMLTurbo.prototype.windowFrameAllHide=function(){
		var total=this.frameWindows.length;
		for(var i=0;i<total;i++){
			this.frameWindows[i].hide();
		}
	}

	HTMLTurbo.prototype.updateTable=function(){


		var total
		var i=0;

		var tableElements=$("table",this.context)
		var tables=Array();
		var table=null;

		total=tableElements.length;
		for(i=0;i<total;i++){
			table=new Table(tableElements.get(i))
			tables.push(table);
		}
		return false;
	}





	HTMLTurbo.prototype.updateIframe=function(){
		var total
		var i=0;

		var iframeElements=$("iframe",this.context)
		var iframes=Array();
		var iframe=null;

		total=iframeElements.length;
		for(i=0;i<total;i++){
			iframe=new Iframe(iframeElements.get(i))
			iframes.push(iframe);
		}
	}
	HTMLTurbo.prototype.updateInput=function(){
		var total
		var i=0;

		var inputElements=$("input",this.context)
		var inputs=Array();
		var input=null;

		total=inputElements.length;

		for(i=0;i<total;i++){
			input=new Input(inputElements.get(i))
			inputs.push(input);
		}
	}
	HTMLTurbo.prototype.updateTextarea=function(){
		var total
		var i=0;

		var textareatElements=$("textarea",this.context)
		var textareas=Array();
		var textarea=null;

		total=textareatElements.length;

		for(i=0;i<total;i++){
			textarea=new Textarea(textareatElements.get(i))
			textareas.push(textarea);
		}
	}
	HTMLTurbo.prototype.updateA=function(){
		var total
		var i=0;

		var aElements=$("a",this.context);
		var as=Array();
		var a=null;

		total=aElements.length;
		for(i=0;i<total;i++){
			a=new A(aElements.get(i));
			as.push(a);
		}
	}



	HTMLTurbo.prototype.updateSelect=function(){
		this.selectElements=Array();
		var elements=$("[class='ht_select']",this.context);
		var total=elements.length;
		for(var i=0;i<total;i++){
			var selectElement=new SelectElement(elements.get(i));
			this.selectElements.push(selectElement)
		}
	}
	/*HTMLTurbo.prototype.updateTabs=function(){
		this.tabss=Array();
		var elements=$("[class='ht_tabs']",this.context);
		var total=elements.length
		for(var i=0;i<total;i++){
			var tabs=new Tabs(elements.get(i),"click");
			this.tabss.push(tabs)
		}
	}*/

	HTMLTurbo.prototype.updateAClick=function(){
		if(top.aClick2Str){
			return ;
		}else {
			top.window.aClick2Str=function(str){
				var list=$(top.document).find("a");
				for(var i=0;i<list.length;i++){
					if(list.eq(i).html()==str){
						list.eq(i).get(0).click();
					}
				}
			}
		}
	}
	HTMLTurbo.prototype.buildDialogAlert=function(msg){
		if(!msg)
			return false;
		var ele=$("<div>",{"class":"dialog","id":"buildNoticeDialog","style":"display:block"});
		var str='<div class="wrapper" style="height:100px">';
		str+='<h4 class="title">提示</h4>';
		str+='<a class="closeButton">close</a>';
		str+='<ul style="height:80px;">';
		str+='<li>'+msg+'</li>';
		str+='</ul>';
		str+='</div>';
		ele.html(str);
		$("body").append(ele);
		$(".closeButton").click(function(){
			$(this).parent().parent(".dialog").remove();
		})
		ele.addClass("open");
		return ele;
	}





	Table=function(selector){
		this.element=$(selector).get(0);
		this.init();
	}
	Table.prototype.init=function(){
		var check=this.element.getAttribute("data-check")
		if(check=="true"){
			this.check();
		}else{
		}
	}
	Table.prototype.check=function(){
		//console.log("table")
		//return false;
		//$("table").each(function(index, element) {
		var thList=[];
		var oldList=$("thead",this.element).find("th");
		for(var i=0;i<oldList.length;i++){
			thList[i]=oldList.eq(i).attr("class");
		}
		var trList=$("tbody",this.element).find("tr");
		for(var i=0;i<trList.length;i++){
			var tdList=trList.eq(i).children("td");
			if(thList.length!=tdList.length&&thList.length>0){
				//console.log("第"+(i+1)+"行tr列中的td数量不一致！标准th是"+thList.length+"个而td实际是"+tdList.length);
			}
			for(var j=0;j<tdList.length;j++){
				if(thList[j]!=tdList.eq(j).attr("class")){
					//console.log("第"+(i+1)+"行"+(j+1)+"列中的class与规定的不一致！标准的class是"+thList[j]+"而实际的td的名称是"+tdList.eq(j).attr("class"))
				}
			}
		}
		//});
	}


	Iframe=function(selector){
		this.element=$(selector).get(0);
		this.init();
	}
	Iframe.prototype.init=function(){
		var self=this;
		this.seamless=$(this.element).attr("seamless");
		if(this.element.src.indexOf("%7B")!="-1"){
			return false;
		}
		if(typeof(this.seamless)!="undefined"){
			var intervalTime=400;
			try{
				window.clearInterval(this.timer);
			}catch(e){}
			this.timer=setInterval(function(){self.update()},intervalTime);
			return ;
			//兼容点设置地方
			/*if(!!document.addEventListener){
				//$(this.element).load(function(event){self.loadCompleteHandle(event);});
				$(this.element).bind("load",function(event){self.loadCompleteHandle(event);});
				//console.log("its up ie8")
			}else{
				this.timer=setInterval(function(){self.update()()},200);
				//console.log("its not up ie8")
			}*/
			//2015.11.24
		}
	}
	Iframe.prototype.loadCompleteHandle=function(event){
		this.adaptiveHeight();
	}
	Iframe.prototype.adaptiveHeight=function(){
		var self=this;
		this.bodyElement=$(this.element).contents().find("body").get(0);
		var height=$(this.bodyElement).outerHeight()
		this.element.style.height=height+"px";
		//console.log("进入了我想走进来的道路");
		$(this.bodyElement).bind("DOMNodeInserted",function(event){
			//var height=$(event.currentTarget).outerHeight()
			var height=$(event.currentTarget).get(0).scrollHeight
			self.element.style.height=height+"px";
		})
		$(this.bodyElement).bind("DOMNodeRemoved",function(event){
			//var height=$(event.currentTarget).outerHeight()
			$(event.currentTarget).css("height","auto");
			$(event.currentTarget).parent("html").css("height","auto");
			var height=$(event.currentTarget).height();
			$(self.element).css("height",height+"px");
		})
	}
	Iframe.prototype.update=function(intervalTime){
		if(this.element.contentWindow.document.body!=null){
			var body=$(this.element.contentWindow.document.body);
			//var body=$(this.element).contents().find("body");
			$(this.element.contentWindow.document.html).css("height","auto");
			// $(this.element).contents().find("html").css("height","auto");
			body.css("height","auto");
			var scrollHeightForBody;
			if(body.length==1){
				scrollHeightForBody=body.height();
			}else{
				scrollHeightForBody=body.height();
			}
			$(this.element).css("height",scrollHeightForBody+"px")
		}

	}



	Input=function(selector){
		this.element=$(selector).get(0)
		this.init();
	}
	Input.prototype.init=function(){
		this.type=this.getType();
		var self=this;
		/*
		20181108 wangyu
		var regExp=new RegExp("^\{");

		if(regExp.test(this.element.value)){
			//console.log(regExp.test(this.element.value)+this.element.value);
			this.element.value="";
		};*/


		var className=this.element.className
		if(className=="ht_dateInput"){
			var regExp=new RegExp("^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$");
			//增加了去空格处理 add by wang at 20161209
			this.element.value= $.trim(this.element.value);
			if(!regExp.test(this.element.value)){
				this.element.value=""
			};
			var dateInput=new DateInput(this.element);
		}

		if(className=="ht_validateCode"){
			var validateCodeImage=new ValidateCodeImage($(this.element).get(0));
			var validateCodeImageElement=validateCodeImage.getElement();
			$(this.element).after(validateCodeImageElement);
		}


		/*if(this.type=="date"){
			var regExp=new RegExp("^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$");

			if(!regExp.test(this.element.value)){
				this.element.value=""
			};
			this.element.type="text"
			//this.element.style.width="120px"
			var options={}
			options.editable=false
			//options.buttons=buttons

			var className=this.element.className

			if(className=="ht_dateInput"){
				var dateInput=new DateInput(this.element);
			}else{
				alert("拥有 datebox");
				$(this.element).datebox(options)
			}
		}*/
		$(this.element).bind("click",function(event){return self.clickHandle(event)});
	}

	Input.prototype.clickHandle=function(event){
		if(this.type=="submit"){
			this.formAction=this.getFormAction();
			var formElement=this.getParentForm(this.element);

			if(typeof(this.formAction)!="undefined"){
				$(formElement).attr("action",this.formAction)
			};
		}
		return true;
	}

	Input.prototype.getFormAction=function(){
		return $(this.element).attr("formaction")
	}
	Input.prototype.getType=function(){
		return this.element.getAttribute("type");
	}


	Input.prototype.getParentForm=function(element){
		var parentNode=element.parentNode;
		var nodeName=parentNode.nodeName
		//alert(nodeName);
		if(nodeName!="FORM" && nodeName!="BODY"){
			return this.getParentForm(parentNode);
		}else{
			return parentNode;
		}
	}

	Textarea=function(selector){
		this.element=$(selector).get(0)
		this.init();
	}
	Textarea.prototype.init=function(){
		var self=this;
		/*  20181108 wangyu
		var regExp=new RegExp("^\{");
		if(regExp.test(this.element.value)){
			this.element.value="";
		};*/
	}

	A=function(selector){
		this.element=$(selector).get(0);
		this.init();
	}
	A.prototype.init=function(){
		this.update();
	}
	A.prototype.update=function(){
		var self=this;
		if(this.element.getAttribute("href")==""){
			this.element.removeAttribute("href")
		}

		/*if(this.element.getAttribute("href")=="" || this.element.getAttribute("href")=="#" || "" || typeof(this.element.getAttribute("href"))=="object"){
			this.element.removeAttribute("href")
			this.element.removeAttribute("target")
		}*/
		// $(this.element).bind("click",function(event){return self.clickHandle(event)})
		$(this.element).unbind("click",self.clickHandle);
		$(this.element).bind("click",self.clickHandle);
		if(!!$(this.element).attr("confirmAction")){
			$(this.element).data("signVal","true");

		}

		if(this.element.target=="autoWindowFrame"){
			var src=$(this.element).attr("href")
			var title=this.element.getAttribute("title")
			if(src!="" && typeof(src)!="undefined"){
				top.windowFrameOpen(title,src,window);
			}
		}
	}
	A.prototype.clickHandle=function(event){
		var self=this;
		var event=event||window.event;
		this.element=event.currentTarget;

		//点击完后变到已查看 viewed状态
		if($(this.element).attr("changeFontWeight")!="false"){
			if($(this.element).hasClass("clickToViewed")||$(this.element).hasClass("unViewed")||$.trim($(this.element).attr("id"))=="viewHref"){
				// this.element.className+=" viewed";
				/*if($.trim($(this.element).text())=="查看"){
                    $(this.element).text("已查看")
				}*/
				try{
					var parentNode=$(this.element).parent().parent().get(0);
					var aElements=$(parentNode).find("a.clickToViewed,a.unViewed");
					for(var i=0;i<aElements.length;i++){
						aElements.eq(i).removeClass("clickToViewed").removeClass("unViewed")
						aElements.eq(i).addClass("viewed")
					}
				}catch(errors){
					console.log(errors);
				}
			}
		}
		var href=this.element.getAttribute("href")
		var title=this.element.getAttribute("title")
		//20161125 add by wangyu
		if(!!$(this.element).attr("confirmAction")&&$(this.element).data("signVal")=="true"){
			/*if(!confirm($(this.element).attr("confirmAction"))){
				return false;
			}*/
			$(this.element).data("signVal","false");
			if(href!="" && href!="#" && typeof(href)!="undefined" && href!=null){
				href=this.element.href
				var options={
					ele:$(self.element),
					param:event,
					yesStr:$(self.element).attr("yesStr")?$(self.element).attr("yesStr"):"确定",
					noStr:$(self.element).attr("noStr")?$(self.element).attr("noStr"):"取消",
					confirmMsg:$(self.element).attr("confirmAction")?$(self.element).attr("confirmAction"):"确定要继续吗",
					titleStr:$(self.element).attr("titleStr")?$(self.element).attr("titleStr"):"提示",
				}
				console.log(options)
				var wfo=windowFrameOpen(title,href,window,"","",options);

			}
			return false;
		}
		if(this.element.target=="windowFrame"){
			if(href!="" && href!="#" && typeof(href)!="undefined" && href!=null){
				href=this.element.href
				//add 20160830 by wangyu   判断父层对象是否存在如果没有就自行新建对象。
				var frameWindow=new FrameWindow();
				window.openedFrameWindow=top.windowFrameOpen?top.windowFrameOpen(title,href,window,""):frameWindow.open(title,href,top.window,"");
			}
			return false;
		}
		if(this.element.target=="largeWindowFrame"){
			if(href!="" && href!="#" && typeof(href)!="undefined" && href!=null){
				href=this.element.href
				window.openedFrameWindow=top.windowFrameOpen(title,href,window,"large");
			}
			return false;
		}
		if(this.element.target=="smallWindowFrame"){
			if(href!="" && href!="#" && typeof(href)!="undefined" && href!=null){
				href=this.element.href
				window.openedFrameWindow=top.windowFrameOpen(title,href,window,"small");
			}
			return false;
		}


		if(this.element.target=="fullScreenWindowFrame"){
			if(href!="" && href!="#" && typeof(href)!="undefined" && href!=null){
				href=this.element.href
				window.openedFrameWindow=top.windowFrameOpen(title,href,window,"fullScreen");
			}
			return false;
		}
		if(this.element.target=="freeWindowFrame"){
			if(href!="" && href!="#" && typeof(href)!="undefined" && href!=null){
				href=this.element.href
				window.openedFrameWindow=top.windowFrameOpen(title,href,window,"free");
			}
			return false;
		}

		if(this.element.getAttribute("target")=="_blank"){
			if(href=="" || href=="#"){
				return false;
			}
		}
		/*
		if(this.element.target=="windowFrame"){
			var href=this.element.href
			var title=this.element.title
			//console.log(window)
			//alert(href.indexOf("##"))
			if(href.indexOf("##")==-1 || !href.indexOf("##")){
				window.openedFrameWindow=top.windowFrameOpen(title,href,window);
			}
			return false;

		}
		 */

	}









	Dialog=function(selector){
		this.element=$(selector).get(0)
		/*if(this.element!=null){
			this.init();
		}*/
	}
	Dialog.prototype.init=function(){
		var title=this.getTitle()
		var self=this;
		if(title!=""){
			//this.element.className="dialog close"
			$(this.element).addClass("close")
			setTimeout(function(){self.open()} ,50)
			//setTimeout(function(){self.close()} ,5000)
		}else{
			this.element.style.display="none"
		}
		$(this.element).find("[class=closeButton]").eq(0).bind("click",function(event){self.closeButtonClickHandle(event);})
		$("form").bind("click",function(event){self.closeButtonClickHandle(event);})
	}
	Dialog.prototype.closeButtonClickHandle=function(event){
		this.close();
	}

	Dialog.prototype.getTitle=function(){
		var title=""
		try{
			title=this.element.children[0].children[0].innerHTML
		}catch(error){
			console.log("no title element")
		}
		return title;
	}
	Dialog.prototype.open=function(){
		//alert("open");
		//this.element.className="dialog open"
		$(this.element).removeClass("close")
		$(this.element).addClass("open")
		this.element.style.display="block"
		//$(this.element).animate({opacity:'100'},500);
		return this;
	}
	Dialog.prototype.close=function(){
		//alert("close");
		//this.element.className="dialog close"
		$(this.element).removeClass("open")
		$(this.element).addClass("close")
		var self=this;
		$(this.element).stop()
		setTimeout(function(){
			self.element.style.display="none"
		} ,500)
		/*$(this.element).animate({opacity:'0'},500,function(){
			self.element.style.display="none"
			//$(self.element).hide()
		});*/
		return this;
	}





	//分页
	Pagination=function(selector){
		this.element=$(selector).get(0)
		this.init()
	}
	Pagination.prototype.init=function(){
		var self=this;
		if(typeof(this.element)!=="undefined"){
			$("#pageNum",this.element).unbind("change")
			$("#pageNum",this.element).bind("change",function(event){self.pageNumChangeHandle(event)})

			$("[name=pageNum]",this.element).next().unbind("click")
			$("[name=pageNum]",this.element).next().bind("click",function(event){return self.pageNumSubmitButtonClickHandle(event)})
		};

		$("[name='pageNum']").unbind("keydown")
		$("[name='pageNum']").bind("keydown",function(event){return self.pageNumKeydownHandle(event)})


		$(".first",this.element).prepend(" ");
		$(".prev",this.element).prepend(" ");
		$(".next",this.element).prepend(" ");
		$(".last",this.element).prepend(" ");
	}


	//添加按钮回车时验证
	Pagination.prototype.pageNumKeydownHandle=function(event){
		var success=false;
		if (event.keyCode != 13)
		{
			return true;
		}
		success=this.pageNumSubmitButtonClickHandle(event)
		if(success){
			success=this.pageNumChangeHandle(event)
		}
		return success;
	}
	Pagination.prototype.pageNumChangeHandle=function(event){
		var regExp=new RegExp(/^[1-9]{1}[0-9]{0,9}$/)
		if(!regExp.test($("#pageNum",this.element).val())){
			$("#pageNum",this.element).val("");
			alert("请输入正确的数字页码,最多输入10位");
			return false;
		}
		return true;
	}
	Pagination.prototype.pageNumSubmitButtonClickHandle=function(event){
		var regExp=new RegExp(/^[1-9]{1}[0-9]{0,9}$/)
		if($("#pageNum",this.element).val()==""){
			alert("页码不能为空，请输入");
			return false;
		}
		if(!regExp.test($("#pageNum",this.element).val())){
			$("#pageNum",this.element).val("")
			alert("请输入正确的数字页码,最多输入10位");
			return false;
		}
		return true;
	}


	ThousandSeparatorNumberContainer=function(selector){
		this.element=$(selector).get(0);
		this.init()
	}
	ThousandSeparatorNumberContainer.prototype.init=function(){
		var value=this.element.innerHTML
		this.element.innerHTML=HTMLTurbo.ThousandSeparatorNumber.valueOf(value);
	}
	ChineseAmountContainer=function(selector){
		this.element=$(selector).get(0);
		this.init()
	}
	ChineseAmountContainer.prototype.init=function(){
		var value=this.element.innerHTML
		this.element.innerHTML=HTMLTurbo.ChineseAmount.valueOf(value);
	}



	HTMLTurbo.ThousandSeparatorNumberInput=ThousandSeparatorNumberInput;
	HTMLTurbo.ThousandSeparatorNumber=ThousandSeparatorNumber
	HTMLTurbo.ChineseAmount=ChineseAmount


	module.exports = HTMLTurbo;
});